package com.qf.utils;

import com.alibaba.fastjson.JSONObject;
import com.qf.pojo.po.XcUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class UserUtils {
    @Autowired
    RedisTemplate redisTemplate;
    public XcUser getUserByToken(String token){
        Boolean aBoolean = redisTemplate.hasKey(token);
        if (!aBoolean){
            return null;
        }
        Object o = redisTemplate.opsForValue().get(token);
        XcUser xcUser = JSONObject.parseObject(JSONObject.toJSONString(o), XcUser.class);
        return xcUser;
    }
}
